<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Application Configuration</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf.tutorials.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.yaf-application.html">Yaf_Application</a></div>
 <div class="up"><a href="book.yaf.html">Yaf</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="yaf.appconfig" class="chapter">
 <h1>Application Configuration</h1>

 <p class="para">
  你需要给出一个config的数组或者ini文件(参见
  <a href="class.yaf-config-ini.html" class="classname">Yaf_Config_Ini</a>) 用来传入
  <span class="methodname"><a href="yaf-application.construct.html" class="methodname">Yaf_Application::__construct()</a></span>. 
 </p>
 <p class="para">
  Yaf和用户共用一个配置空间, 也就是在Yaf_Application初始化时刻给出的配置文件中的配置. 作为区别, Yaf的配置项都以&quot;yaf.&quot;或者&quot;application.&quot;开头,如果同一个配置项同时使用了&quot;yaf.&quot;和&quot;application.&quot;，那么&quot;application.&quot;会生效，而&quot;yaf.&quot;不会.
  <div class="example" id="example-4015">
   <p><strong>Example #1 config为数组的例子</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$configs&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"application"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"directory"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"dispatcher"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"catchException"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"view"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"ext"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"phtml"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$app&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Yaf_Application</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-4016">
   <p><strong>Example #2 config为ini文件的例子</strong></p>
   <div class="example-contents">
<div class="inicode"><pre class="inicode">[yaf]
yaf.directory = APPLICATION_PATH &quot;/appliation&quot;
yaf.dispatcher.catchException = 0

[product : yaf]
; user configuration list here</pre>
</div>
   </div>

  </div>
  </p>
  <p class="para">
  <table class="doctable table">
   <caption><strong>Yaf Application Config</strong></caption>
   
    <thead>
     <tr>
      <th>名字</th>
      <th>默认</th>
      <th>更新日志</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>application.directory</td>
      <td class="empty">&nbsp;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.ext</td>
      <td>&quot;php&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.view.ext</td>
      <td>&quot;phtml&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.modules</td>
      <td>&quot;index&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.library</td>
      <td>application.directory . &quot;/library&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.library.directory</td>
      <td>application.directory . &quot;/library&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.library.namespace</td>
      <td>&quot;&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.bootstrap</td>
      <td>application.directory . &quot;/Bootstrap&quot; . application.ext</td>
      <td></td>
     </tr>

     <tr>
      <td>application.baseUri</td>
      <td>&quot;&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.dispatcher.defaultRoute</td>
      <td class="empty">&nbsp;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.dispatcher.throwException</td>
      <td>1</td>
      <td></td>
     </tr>

     <tr>
      <td>application.dispatcher.catchException</td>
      <td>0</td>
      <td></td>
     </tr>

     <tr>
      <td>application.dispatcher.defaultModule</td>
      <td>&quot;index&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.dispatcher.defaultController</td>
      <td>&quot;index&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.dispatcher.defaultAction</td>
      <td>&quot;index&quot;</td>
      <td></td>
     </tr>

     <tr>
      <td>application.system</td>
      <td class="empty">&nbsp;</td>
      <td></td>
     </tr>

    </tbody>
   
  </table>

 </p>

 <p class="para">这是配置指令的简短说明。</p>

 <p class="para">
  <dl>

   
     <dt id="configuration.yaf.directory">
      <em><code class="parameter">application.directory</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       用来指定&quot;controllers&quot;, &quot;views&quot;, &quot;models&quot;, &quot;plugins&quot;的目录.
      </p>
      <p class="para">
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
         这是唯一一个没有默认值的配置项，你需要手动指定它.
        </p>
       </p></blockquote>
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.ext">
      <em><code class="parameter">application.ext</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       PHP脚本的扩展名
       <a href="class.yaf-loader.html" class="classname">Yaf_Loader</a>).
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.view.ext">
      <em><code class="parameter">application.view.ext</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       视图模板扩展名
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.modules">
      <em><code class="parameter">application.modules</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
      声明存在的模块名,尤其是路径超过3段的模块.
      </p>
      <p class="para">
       Yaf以此来找出路径第一段是否是一个模块的名称.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.library">
      <em><code class="parameter">application.library</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       本地(自身)类库的绝对目录地址, 参见 <a href="class.yaf-loader.html" class="classname">Yaf_Loader</a> 和
       <a href="yaf.configuration.html#ini.yaf.library" class="link">yaf.library</a>.
       </p>
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
         Yaf 2.1.6之后，这个配置项可以是一个数组，当它是数组的时候，类库的路径将尝试使用 <a href="yaf.appconfig.html#configuration.yaf.library.directory" class="link">application.library.directory</a>
          的值
        </p>
       </p></blockquote>
     </dd>

    
    
     <dt id="configuration.yaf.library.directory">
      <em><code class="parameter">application.library.directory</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       Yaf 2.1.6加入
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.library.namespace">
      <em><code class="parameter">application.library.namespace</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       以逗号分隔的本地库命名空间前缀。
      </p>
      <p class="para">
       Yaf 2.1.6加入
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.bootstrap">
      <em><code class="parameter">application.bootstrap</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       Bootstrap路径(绝对路径)
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.baseuri">
      <em><code class="parameter">application.baseUri</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       在路由中, 需要忽略的路径前缀.
       举个例子, 比如&quot;/prefix/controller/action&quot;这样的一个请求. 如果你将application.baseUri设置为&quot;/prefix&quot;, 
       那么只有&quot;/controller/action&quot;会被当做路由路径.
      </p>
      <p class="para">
        通常不需要设置, Yaf会自动判断.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.dispatcher.throwexception">
      <em><code class="parameter">application.dispatcher.throwException</code></em>
      <span class="type"><a href="language.types.boolean.html" class="type bool">bool</a></span>
     </dt>

     <dd>

      <p class="para">
       如果设置为On, Yaf会在发生错误的时候抛出异常，参见<span class="methodname"><a href="yaf-dispatcher.throwexception.html" class="methodname">Yaf_Dispatcher::throwException()</a></span>.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.dispatcher.catchexception">
      <em><code class="parameter">application.dispatcher.catchException</code></em>
      <span class="type"><a href="language.types.boolean.html" class="type bool">bool</a></span>
     </dt>

     <dd>

      <p class="para">
       如果设置为On, Yaf会在捕获到异常的时候跳转到响应的错误页面，参见<span class="methodname"><a href="yaf-dispatcher.catchexception.html" class="methodname">Yaf_Dispatcher::catchException()</a></span>.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.dispatcher.defaulRoute">
      <em><code class="parameter">application.dispatcher.defaultRoute</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       默认路由, 如果没用定义, 那么将使用静态路由来当做默认路由, 参见<span class="methodname"><a href="yaf-router.addroute.html" class="methodname">Yaf_Router::addRoute()</a></span>.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.dispatcher.defaultmodule">
      <em><code class="parameter">application.dispatcher.defaultModule</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       The default module name, see also
       <span class="methodname"><a href="yaf-dispatcher.setdefaultmodule.html" class="methodname">Yaf_Dispatcher::setDefaultModule()</a></span>.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.dispatcher.defaultcontroller">
      <em><code class="parameter">application.dispatcher.defaultController</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       The default controller name, see also
       <span class="methodname"><a href="yaf-dispatcher.setdefaultcontroller.html" class="methodname">Yaf_Dispatcher::setDefaultController()</a></span>.
      </p>
     </dd>

    
    
     <dt id="configuration.yaf.dispatcher.defaultaction">
      <em><code class="parameter">application.dispatcher.defaultAction</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       The default action name, see also
       <span class="methodname"><a href="yaf-dispatcher.setdefaultaction.html" class="methodname">Yaf_Dispatcher::setDefaultAction()</a></span>.
      </p>
     </dd>

    

    
     <dt id="configuration.yaf.system">
      <em><code class="parameter">application.system</code></em>
      <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
     </dt>

     <dd>

      <p class="para">
       Set yaf runtime configure in application.ini, like:
       <a href="yaf.configuration.html#ini.yaf.lowcase-path" class="link">application.system.lowcase_path</a>
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <p class="para">
        only those PHP_INI_ALL configures can be set in this way
       </p>
       </p></blockquote>
      </p>
     </dd>

    

  </dl>

 </p>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="yaf.tutorials.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.yaf-application.html">Yaf_Application</a></div>
 <div class="up"><a href="book.yaf.html">Yaf</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
